New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Realtime decoding #615
Conversation
while 1: | ||
|
||
# Fetch epochs and labels | ||
if (ii==0): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really ugly. I wish I could do without an if condition. Something like epochs = [] outside the loop and then np.append() inside the loop, but that doesn't work ...
do we have some python code to mock the real time server? it will be required for testing. |
Not yet.. I will look into implementing it, should be quite straightforward. |
@mainakjas some general comments. I think it would be good if in the first phase of your gsoc project we go "back to the basics" and first do some experiments with offline learning, this will allow you to see how well different classifiers work, test feature extraction methods, etc. Also, the real-time part currently needs the Regarding the code, make sure you use a pep8 checker, so your code formatting is coherent with the rest of the code (mostly there are many spaces missing). |
thanks for noticing, the PEP8 checker seems to be disabled/broken. I'll check that :) |
@mluessi if you don't want to implement the mock server. You can static build mne_rt_server and provide it as standalone application to the others. |
@agramfort i think its not required - since we are very cross-platform even for embedded systems. You can just static build the server - this would be similiar to the fieldtrip buffer. They provide the bins with the matlab code. |
@chdinh I don't think that's an option.. it will make unit testing of mne-python difficult. It shouldn't be very hard to implement a mock server in Python that just implements the file simulation. |
okay, didn't thought of the unit testing. - Just for my understanding: is it possible to call executables with python code? |
I had a hard time setting up things for the forward model unit tests. On Thu, Jun 6, 2013 at 7:51 PM, Christoph Dinh notifications@github.comwrote:
|
@chdinh it is possible, see the |
thx - same in mne-cpp everything should be written in Qt to not depend on other libs to avoid such issues. Anyway another issue I see is: having a real-time simulator for sampling frequencies up to 5k and doesn't have the ability to parallelize in multiple threads will reduce the possbile calculations per second which mainakjas could use for the classification process. If the simulation is done by mne_rt_server (which allone uses 5 threads), the CPU Core power could be totally used for the classification purpose. |
+100 for a mock server. 1/ if we don't the code will be not be tested on a regular basis |
Real-time M/EEG Acquisition | ||
--------------------------- | ||
|
||
Receive data from an MNE Real-time sever (mne_rt_server, part of MNE-CPP), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sever -> server
I think we really need to sit down and discuss API and use cases. In an online setting you would update the classifier rather than recompute everything is there a way to command the stimulation device ie. do some kind of reinforcement learning? |
Yes, I agree. I think once we know the use cases, it will become more clear what API should be used. I think it would also be good to first do some experiments without the real-time part. E.g., how many epochs do we need to accurately predict the event types, what features work best, etc. Does scikit-learn support online learning, i.e., can classifiers be updated with new samples? I don't think this is the case but it would be very nice.. Regarding reinforcement learning, do you mean modifying the experiment based on the classifier output ("feedback")? This would definitely be nice. I think we should find a way to interface with PsychoPy. The main difficulty is probably that it will run as a separate process, so we could use TCP/IP for interprocess communication. |
+1 to discussing the use cases. same question as martin, can classifiers be updated with new samples in ps: Another use case (this just an idea) I was thinking is the ability to On Thu, Jun 6, 2013 at 11:31 PM, Martin Luessi notifications@github.comwrote:
|
Grep partial_fit and warm_start in sklearn
Yes.
|
Online feature extraction with morlet or filtering and standard BCI techniques like CSP is of higher priority to me |
Simplify realtime API code
event_id, tmin, tmax = 1, -0.2, 0.5 | ||
|
||
# the number of epochs to average | ||
n_epochs = 30 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, this is no longer required. should delete this too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go ahead !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok fixed this.
what all is left to have this branch merged? We have unit tests and
examples - what else? can we go for a good hard review and aim to have this
merged soon?
On Wed, Jul 17, 2013 at 1:51 PM, Alexandre Gramfort <
notifications@github.com> wrote:
In examples/realtime/plot_compute_rt_moving_average.py:
+import pylab as pl
+
+# Fiff file to simulate the realtime client
+data_path = sample.data_path()
+raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif'
+raw = mne.fiff.Raw(raw_fname, preload=True)
+
+# select gradiometers
+picks = mne.fiff.pick_types(raw.info, meg='grad', eeg=False, eog=True,
stim=True, exclude=raw.info['bads'])
+# select the left-auditory condition
+event_id, tmin, tmax = 1, -0.2, 0.5
+
+# the number of epochs to average
+n_epochs = 30go ahead !
—
Reply to this email directly or view it on GitHubhttps://github.com//pull/615/files#r5239140
.
Some things I'd like to do before merge:
any objection on the new mne.decoding module? |
sounds good to me! +1 for mne.decoding module from my end. On Wed, Jul 17, 2013 at 2:50 PM, Alexandre Gramfort <
|
great ! let me know when I shall review. It should not be long. |
+1 for the decoding module. I think it makes sense to keep realtime and decoding separate. |
glad we agree. Finishing this PR should be quick then. @mainakjas go go team ! |
absolutely +1 for all recent proposals. |
ok I was compiling the htmls and it took ages (45 minutes or so) to compile. In the end, when I checked the Q1/ Is there an option to compile just one html ? (to save some time) |
all the examples starting with plot_ should appear. I know it takes time to build the doc but it's hard to have real examples that
it should only rebuild the examples that failed or which were touched.
let me try. |
I observe the same problem. Plots don't appear in the doc. But read this: plot_compute_rt_decoder.py is not compiling: pylab in sphinx does not like the pl.waitforbuttonpress(0.1) |
Thanks @agramfort, I guess I created the decoding module now and updated the authors list. Getting closer ... why do we need to update the manifest.in file? python_reference.rst looks a bit complicated and I need to figure out how things go. More soon! |
+1
let me know when done.
indeed no need as you have no data file.
ok ! |
- Fixed one line in the changelog of whats_new.rst - python_reference.rst was updated but not sure how/which functions to include below the Decoding header
ok, I'm more or less done. Only thing is that I'm confused about |
@@ -65,7 +65,8 @@ | |||
'mne.tests', | |||
'mne.transforms', | |||
'mne.stats', 'mne.stats.tests', | |||
'mne.time_frequency', 'mne.time_frequency.tests'], | |||
'mne.time_frequency', 'mne.time_frequency.tests', | |||
'mne.realtime', 'mne.decoding'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you forgot to add the tests folders for realtime and decoding
besides this LGTM ! |
None as they are all classes as far as I know. |
ok thanks, comments addressed. On Thu, Jul 18, 2013 at 5:58 PM, Alexandre Gramfort <
|
merged by rebase so we have a clean history ! greaj job @mainakjas ! |
This is being built on top of @mluessi's PR: #382. First attempt at building something is a simple decoding example using SVM. My plan is to move much of the code into functions such as rtSVM. It seems to work, but I am surprised at uniformly 100% accuracies - either something wrong with the code or we need to change the categories being decoded.